/**
 * Created by zhtt on 2017/5/6.
 */
var supermarketApp=angular.module('supermarketApp', ['ui.router','ui.bootstrap']);
supermarketApp.config(["$stateProvider","$urlRouterProvider",routeConfig]);

/** 路由设置 **/
function routeConfig($stateProvider,$urlRouterProvider){
    $urlRouterProvider.otherwise("/home");
    $stateProvider
        .state("home",{
            url:"/home",
            controller: 'HomeCtrl', //也可以写成HomeController as home
            controllerAs: 'home',
            templateUrl:"html/home.html"
        })
        .state("goods",{
            url:"/goods",
            controller:"GoodsCtrl",
            controllerAs:"goods",
            templateUrl:"html/goods.html"
        })
        .state("customer",{
            url:"/customer",
            controller:"CustomerCtrl",
            controllerAs:"customer",
            templateUrl:"html/customer.html"
        })
        .state("statistics",{
            url:"/statistics",
            templateUrl:"html/statistics.html"
        })
        .state("system",{
            url:"/system",
            controller:"SystemCtrl",
            controllerAs:"system",
            templateUrl:"html/system.html"
        })
}

supermarketApp.run(function ($rootScope, $state, $timeout) {
    $rootScope.systemName=config.systemName;
    $rootScope.systemCopyright=config.systemCopyright;
    $rootScope.menu={
        navMenuCrt:'home',
        userMenus:config.navMenu
    };
    function init() {
        initEvent();
    }
    init();
    //初始化事件
    function initEvent() {
        $rootScope.$watch('menu.navMenuCrt', function () {
            $rootScope.navCollapsed = true;
        });
    }
    $rootScope.$watch('menu.navMenuCrt', function () {
        $rootScope.navCollapsed = true;
    });
});